package com.ctgu.蓝桥杯真题.B组2016;

import java.io.*;
import java.util.Arrays;

/**
 * @author: Backdiy
 * @data: 2021/4/14 15:44
 * @desc:
 */
public class C凑算式 {
    static int ans = 0;

    public static void main(String[] args) {
        int[] num = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
        p(num, 0, 8);
        IO.out.println(ans);
        IO.out.flush();
    }

    static void p(int[] num, int s, int e) {
        if (s == e) {
            double a = num[0];
            double b = num[1];
            double c = num[2];
            double x = num[3] * 100 + num[4] * 10 + num[5];
            double y = num[6] * 100 + num[7] * 10 + num[8];
            double d = (b*y+c*x)/(c*y);
            double z = a + d;
            if (z==10) {
                ans++;
            }
        } else {
            for (int i = s; i <= e; i++) {
                swap(num, s, i);
                p(num, s + 1, e);
                swap(num, s, i);
            }
        }
    }

    static void swap(int[] num, int st, int ed) {
        int t = num[st];
        num[st] = num[ed];
        num[ed] = t;
    }

    static class IO {
        static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        static public int nextInt() throws IOException {
            in.nextToken();
            return (int) in.nval;
        }

        static public double nextDouble() throws IOException {
            in.nextToken();
            return in.nval;
        }

        static public String readLine() throws IOException {
            return read.readLine();
        }

        static public String nextLine() throws IOException {
            in.nextToken();
            return in.sval;
        }
    }
}
